home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 131 / XENIATGM131.iso / Shareware / openOffice.org 641 / Windows / f_0250 / Main.xba < prev    next >
Extensible Markup Language  |  2001-11-15  |  8KB  |  264 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
  3. <script:module xmlns:script="http://openoffice.org/2000/script" script:name="Main" script:language="StarBasic">Option Explicit
  4.  
  5. '  *****  BASIC  *****
  6. ' Todo: Problematik der VBA-Makros, die angeblich nicht mit abgespeichert werden koennen.
  7. ' Evt. Erkennen der Arbeitsverzeichnisse von MS Office
  8. Public HeaderPreviews(4) as Object
  9. Public ImportDialog as Object
  10. Public ImportDialogArea as Object
  11. Public bSetFonts as Boolean
  12. ' If the ProgressPage ist already on Top The Dialog will be immediately closed when this flag is
  13. ' set to False
  14. Public bConversionIsRunnig as Boolean
  15. Public oFactoriesAccess as Object
  16.  
  17. Sub Main()
  18. Dim RetValue as Integer
  19.     If Not bDebugWizard Then
  20.         On Local Error Goto RTError
  21.     End If
  22.     BasicLibraries.LoadLibrary("Tools")
  23.     bSetFonts = False
  24.     bConversionIsRunnig = False
  25.     If bSetFonts Then
  26.         BasicLibraries.LoadLibrary("Translater")
  27.         GetFontNames()
  28.     End If
  29.     sCRLF = CHR(10) & CHR(13)
  30.     oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
  31.     oFactoriesAccess = GetRegistryKeyContent("org.openoffice.Setup/Office/Factories")
  32.     SOBitmapPath = GetOfficeSubPath("Template", "wizard/bitmap")
  33.     SOWorkPath = GetPathSettings("Work", False)
  34.     SOTemplatePath = GetPathSettings("Template",False,1)
  35.       bCancelTask = False
  36.       bDoKeepApplValues = False
  37.     CurOffice = 0
  38.     ImportDialogArea = LoadDialog("ImportWizard","ImportDialog")
  39.     ImportDialog = ImportDialogArea.Model
  40.     LoadLanguage()
  41.     WizardMode = SBXMLMODE
  42.     MaxApplCount = 4
  43.     FillStep_Welcome()
  44.     RepaintHeaderPreview()
  45.     ImportDialog.cmdGoOn.DefaultButton = True
  46.     ImportDialogArea.GetControl("optSODocuments").SetFocus()
  47.     RetValue = ImportDialogArea.Execute()
  48.     If RetValue = 0 Then
  49.         CallCancelTask()
  50.     End If
  51.     ImportDialogArea.Dispose()
  52.     End
  53.     Exit Sub
  54. RTError:
  55.     Msgbox sRTErrorDesc, 16, sRTErrorHeader
  56. End Sub
  57.  
  58.  
  59. Sub NextStep
  60. Dim iCurStep as Integer
  61.     If Not bDebugWizard Then
  62.         On Error Goto RTError
  63.     End If
  64.     bConversionIsRunnig = False
  65.     iCurStep = ImportDialog.Step
  66.  
  67.     Select Case iCurStep
  68.         Case 1
  69.             FillStep_InputPaths(0, True)
  70.         Case 2
  71.             If CheckInputPaths Then
  72.                 SaveStep_InputPath
  73.                 If CurOffice < ApplCount - 1 Then
  74.                     CurOffice = CurOffice + 1
  75.                     TakeOverPathSettings()
  76.                     FillStep_InputPaths(CurOffice, False)
  77.                 Else
  78.                     FillStep_Summary()
  79.                 End If
  80.             End If
  81.         Case 3
  82.             FillStep_Progress()
  83.             Select Case WizardMode
  84.                 Case SBMICROSOFTMODE
  85.                     Call ConvertAllDocuments(MSFilterName())
  86.                 CASE SBXMLMODE
  87.                     Call ConvertAllDocuments(XMLFilterName())
  88.             End Select
  89.         Case 4
  90.             CancelTask(True)
  91.     End Select
  92.     ImportDialog.cmdGoOn.DefaultButton = True
  93.     RepaintHeaderPreview()    
  94.     Exit Sub
  95. RTError:
  96.     Msgbox sRTErrorDesc, 16, sRTErrorHeader
  97. End Sub
  98.  
  99.  
  100. Sub PrevStep()
  101. Dim iCurStep as Integer
  102.     If Not bDebugWizard Then
  103.         On Error Goto RTError
  104.     End If
  105.     bConversionIsRunnig = False
  106.     iCurStep = ImportDialog.Step
  107.     Select Case iCurStep
  108.         Case 4
  109.             ImportDialog.cmdCancel.Label = sCancelButton
  110.             FillStep_Summary()
  111.         Case 3
  112.             FillStep_InputPaths(Applcount-1, False)
  113.         Case 2
  114.             SaveStep_InputPath
  115.             If CurOffice > 0 Then
  116.                 CurOffice = CurOffice - 1
  117.                 FillStep_InputPaths(CurOffice, False)
  118.             Else
  119.                 FillStep_Welcome()
  120.                 bDoKeepApplValues = True
  121.             End If
  122.     End Select
  123.     ImportDialog.cmdGoOn.DefaultButton = True
  124.     RepaintHeaderPreview()    
  125.     Exit Sub
  126. RTError:
  127.     Msgbox sRTErrorDesc, 16, sRTErrorHeader
  128. End Sub
  129.  
  130.  
  131. Sub CallCancelTask()
  132.     CancelTask(True)
  133. End Sub
  134.  
  135. Sub CancelTask(bCloseDialog as Boolean)
  136.     If bConversionIsRunnig Then
  137.         If Msgbox(sConvertError1, 36, sConvertError2) = 6 Then
  138.             If bCloseDialog Then
  139.                 ImportDialogArea.EndExecute
  140.             End If
  141.             bCancelTask = True
  142.         Else
  143.             bCancelTask = False
  144.             ImportDialog.cmdCancel.Enabled = True
  145.         End If
  146.     Else
  147.         ImportDialogArea.EndExecute()    
  148.     End If
  149. End Sub
  150.  
  151.  
  152. Sub TemplateDirSearchDialog()
  153.     CallDirSearchDialog(ImportDialog.TemplateImportPath)
  154. End Sub
  155.  
  156.  
  157. Sub RepaintHeaderPreview()
  158. Dim Bitmap As Object
  159. Dim CurStep as Integer
  160. Dim sBitmapPath as String
  161. Dim LocPrefix as String
  162.     CurStep = ImportDialog.Step
  163.     LocPrefix = WizardMode
  164.     LocPrefix = ReplaceString(LocPrefix,"XML", "SO")
  165.     If CurStep = 2 Then
  166.         sBitmapPath = SOBitmapPath & LocPrefix & "-Import_" & CurStep & "-" & Applications(CurOffice,SBAPPLKEY) + 1 & ".bmp"
  167.     Else
  168.         sBitmapPath = SOBitmapPath & "Import_" & CurStep & ".bmp"
  169.     End If
  170.     ImportDialog.ImportPreview.ImageURL = sBitmapPath
  171. End Sub
  172.  
  173.  
  174. Sub CheckModuleInstallation()
  175. Dim i as Integer
  176.     For i = 1 To MaxApplCount
  177.         ImportDialogArea.GetControl("chk" & WizardMode & "Application" & i).Model.Enabled = Abs(CheckInstalledModule(i-1))
  178.     Next i
  179. End Sub
  180.  
  181.  
  182. Function CheckInstalledModule(Index as Integer) as Boolean
  183. Dim ModuleName as String
  184. Dim NameList() as String
  185. Dim MaxIndex as Integer
  186. Dim i as Integer
  187.     ModuleName = ModuleList(Index)
  188.     If Instr(1,ModuleName,"/") <> 0 Then
  189.         NameList() = ArrayoutOfString(ModuleName,"/", MaxIndex)
  190.         For i = 0 To MaxIndex
  191.             If oFactoriesAccess.HasByName(NameList(i)) Then
  192.                 CheckInstalledModule() = True
  193.                 Exit Function
  194.             End If
  195.         Next i
  196.         CheckInstalledModule() = False
  197.     Else
  198.         CheckInstalledModule() = oFactoriesAccess.HasByName(ModuleName)
  199.     End If
  200. End Function
  201.  
  202.  
  203. Sub ToggleCheckboxes(oEvent as Object)
  204. Dim bMSEnable as Boolean
  205.     WizardMode = oEvent.Source.Model.Tag
  206.     bMSEnable = WizardMode = "MS"
  207.     If WizardMode = "MS" Then
  208.         MaxApplCount = 3
  209.     Else
  210.         MaxApplCount = 4
  211.     End If
  212.     With ImportDialogArea
  213.         .GetControl("chkSOApplication1").Model.Enabled = Not bMSEnable
  214.         .GetControl("chkSOApplication2").Model.Enabled = Not bMSEnable
  215.         .GetControl("chkSOApplication3").Model.Enabled = Not bMSEnable
  216.         .GetControl("chkSOApplication4").Model.Enabled = Not bMSEnable
  217.         .GetControl("chkMSApplication1").Model.Enabled = bMSEnable
  218.         .GetControl("chkMSApplication2").Model.Enabled = bMSEnable
  219.         .GetControl("chkMSApplication3").Model.Enabled = bMSEnable
  220.     End With
  221.     CheckModuleInstallation()
  222.     ImportDialog.WelcomeTextLabel2.Enabled = bMSEnable
  223.     bDoKeepApplValues = False
  224.     ToggleNextButton()
  225. End Sub
  226.  
  227.  
  228. Sub ToggleNextButton()
  229. Dim iCurStep as Integer
  230. Dim bDoEnable as Boolean
  231. Dim i as Integer
  232.     iCurStep = ImportDialog.Step
  233.     Select Case iCurStep
  234.         Case 1
  235.             With ImportDialog
  236.                 If .optMSDocuments.State = 1 Then
  237.                       bDoEnable = .chkMSApplication1.State = 1 Or .chkMSApplication2.State = 1 Or .chkMSApplication3.State = 1
  238.                 Else
  239.                       bDoEnable = .chkSOApplication1.State = 1 Or .chkSOApplication2.State = 1 Or .chkSOApplication3.State = 1 Or .chkSOApplication4.State = 1
  240.                 End If
  241.             End With
  242.             bDoKeepApplValues = False
  243.         Case 2
  244.             bDoEnable = CheckControlPath(ImportDialog.chkTemplatePath, ImportDialog.txtTemplateImportPath, True)
  245.             bDoEnable = CheckControlPath(ImportDialog.chkDocumentPath, ImportDialog.txtDocumentImportPath, bDoEnable)
  246.     End Select
  247.     ImportDialog.cmdGoOn.Enabled = bDoEnable
  248. End Sub
  249.  
  250.  
  251. Sub TakeOverPathSettings()                    
  252. 'Takes over the Pathsettings from the first selected application to the next applications
  253.     If Applications(CurOffice,SBDOCSOURCE) = "" Then
  254.         Applications(CurOffice,SBDOCSOURCE) = Applications(0,SBDOCSOURCE)
  255.         Applications(CurOffice,SBDOCTARGET) = Applications(0,SBDOCTARGET)
  256.         If WizardMode = SBXMLMODE AND Applications(CurOffice,SBAPPLKEY) = 3 Then
  257.             Applications(CurOffice,SBTEMPLSOURCE) = Applications(CurOffice,SBDOCSOURCE)
  258.             Applications(CurOffice,SBTEMPLTARGET) = Applications(CurOffice,SBDOCTARGET)                                            
  259.         Else
  260.             Applications(CurOffice,SBTEMPLSOURCE) = Applications(0,SBTEMPLSOURCE)
  261.             Applications(CurOffice,SBTEMPLTARGET) = Applications(0,SBTEMPLTARGET)                    
  262.         End If
  263.     End If
  264. End Sub</script:module>